/**
 * Copyright 2004 - 2007 Blue Bamboo International Inc. 
 *           All rights reserved.
 *
 *
 * Blue Bamboo PROPRIETARY/CONFIDENTIAL.
 *
 */

package com.bluebamboo.bluetools.pingpang.bean;

import static org.junit.Assert.*;

import gnu.io.SerialPort;

import java.util.List;

import org.junit.Test;

/**
 * DOCME
 * 
 * @author tanxuqing
 * @date Sep 13, 2009
 * @since
 */
public class ConnectionBeanManagerTest {

    private ConnectionBeanManager beanManager;

    public ConnectionBeanManagerTest() {
        beanManager = ConnectionBeanManager.getInstance();
    }

    @Test
    public void listConnection() throws Exception {
        List<ConnectionBean> beans = beanManager.listConnections();
        assertEquals(0, beans.size());
    }

    @Test
    public void addConnection() throws Exception {
        List<ConnectionBean> beans = beanManager.listConnections();
        int sizeBeforeAdd = beans.size();

        ConnectionBean newSerialBean = new SerialBean("COM1", "COM1", 115200, SerialPort.STOPBITS_1,
                SerialPort.DATABITS_8, SerialPort.PARITY_NONE, SerialPort.FLOWCONTROL_RTSCTS_IN);
        beanManager.addConnection(newSerialBean);
        assertEquals(++sizeBeforeAdd, beanManager.listConnections().size());

        ConnectionBean newSocketServerBean = new SocketServerBean("Test9900", ConnectionBean.TYPE_TCP_SERVER, 9900);
        beanManager.addConnection(newSocketServerBean);
        assertEquals(++sizeBeforeAdd, beanManager.listConnections().size());
    }

    @Test
    public void addExistingConnection() throws Exception {

    }

    @Test
    public void deleteConnection() throws Exception {

    }

    @Test
    public void deleteRunningConnection() throws Exception {

    }
}
